import {
  ArgumentMetadata,
  Injectable,
  PipeTransform,
  BadRequestException,
} from '@nestjs/common';

@Injectable()
export class ValidatePipe implements PipeTransform {
  transform(value: any, metadata: ArgumentMetadata) {
    console.log('管道运行了~~~', value);
    if (Number.isNaN(parseInt(value))) {
      console.log('参数错误');
      throw new BadRequestException(`参数${metadata.data}错误`);
    }
    return value;
  }
}
